#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>

int main(int argc, char**argv)
{
    //打开bmp文件
    int fd = open(argv[1], O_RDONLY);
    if(fd == -1)
    {
        perror("open bmp error:");
        return -1;
    }

    //操作
    //读取数据:魔数
    char buf[2];
    read(fd, buf,2);
    if(buf[0] != 'B' || buf[1] != 'M')
    {
        printf("No\n");
        close(fd);
        return -1;
    }
    printf("Yes\n");

    //宽
    //char data_buf[4];
    int w,h,size;
    lseek(fd, 0x12, SEEK_SET);
    read(fd,&w, 4);

    //高
    read(fd,&h, 4);

    //文件大小
    lseek(fd, 0x02, SEEK_SET);
    read(fd,&size, 4);

    //色深
    short depth = 0;
    lseek(fd, 0x1c, SEEK_SET);
    read(fd,&depth, 2);

    printf("%d %d %d %hd\n", w, h, size, depth);
  
    //关闭文件
    close(fd);
}